import java.util.Scanner;

public class Good {
    private String number; //编号
    private String name;
    private String manufacturer; //生产厂家
    private String dateOfProduced;
    private String type;
    private double purchasingCost;
    private double price;
    private int count;

    public void setName(String name){this.name = name;}
    public void setNumber(String number){this.number = number;}
    public void setManufacturer(String manufacturer){this.manufacturer = manufacturer;}
    public void setDateOfProduced(String dateOfProduced){this.dateOfProduced = dateOfProduced;}
    public void setPurchasingCost(double purchasingCost){this.purchasingCost = purchasingCost;}
    public void setPrice(double price){this.price = price;}
    public void setCount(int count){this.count = count;}
    public void setType(String type){this.type = type;}
    public String getType(){return type;}
    public String getNumber(){return number;}
    public String getName(){return name;}
    public String getManufacturer(){return manufacturer;}
    public String getDateOfProduced(){return dateOfProduced;}
    public double getPurchasingCost(){return purchasingCost;}

    public int getCount() {return count;}
    public double getPrice(){return price;}
    public void show(){
        System.out.println("商品编号:"+getNumber()+"   商品名称:"+getName()+"   生产厂家:"+getManufacturer()+"   生产日期:"+getDateOfProduced()+
                "   型号:"+getType()+"   进货价:"+getPurchasingCost()+"   零售价格:"+getPrice()+"   数量:"+getNumber());
    }
    public void showLittle(){
        System.out.print("商品编号:"+getNumber()+"   商品名称:"+getName() + "   商品数量"+getCount());
    }
    public void change(){
        Scanner input = new Scanner(System.in);
        System.out.println("请选择要修改的内容：");
        System.out.println("1--商品编号\n2--商品名称\n3--生产厂家\n4--生产日期\n5--型号\n6--进货价\n7--零售价格\n8--数量。");
        int choose = 0;
        try {
            choose = input.nextInt();
        }catch (Exception e){
            System.out.println("输入不合法，请重新输入。");
            while (input.hasNext()) {
                if (input.hasNextLine()) {
                    input.nextLine();
                    break;
                } else {
                    input.next();
                }
            }
            change();
            return;
        }
        switch (choose){
            case 1:
                System.out.println("请输入新的商品编号：");
                setNumber(input.next());
                break;
            case 2:
                System.out.println("请输入新的商品名称：");
                setName(input.next());
                break;
            case 3:
                System.out.println("请输入新的生产厂家：");
                setManufacturer(input.next());
                break;
            case 4:
                System.out.println("请输入新的生产日期：");
                setDateOfProduced(input.next());
                break;
            case 5:
                System.out.println("请输入新的型号：");
                setType(input.next());
                break;
            case 6:
                double buy = 0;
                System.out.println("请输入新的进货价：");
                try {
                    buy = input.nextDouble();
                }catch (Exception e){
                    System.out.println("输入不合法，请重新输入。");
                    while (input.hasNext()) {
                        if (input.hasNextLine()) {
                            input.nextLine();
                            break;
                        } else {
                            input.next();
                        }
                    }
                    change();
                    return;
                }
                setPurchasingCost(buy);
                break;
            case 7:
                double price = 0;
                System.out.println("请输入新的零售价格：");
                try {
                    price = input.nextDouble();
                }catch (Exception e){
                    System.out.println("输入不合法，请重新输入。");
                    while (input.hasNext()) {
                        if (input.hasNextLine()) {
                            input.nextLine();
                            break;
                        } else {
                            input.next();
                        }
                    }
                    change();
                    return;
                }
                setPrice(price);
                break;
            case 8:
                int cnt = 0;
                System.out.println("请输入新的商品数量：");
                try {
                    cnt = input.nextInt();
                }catch (Exception e){
                    System.out.println("输入不合法，请重新输入。");
                    while (input.hasNext()) {
                        if (input.hasNextLine()) {
                            input.nextLine();
                            break;
                        } else {
                            input.next();
                        }
                    }
                    change();
                    return;
                }
                if(cnt < 0){
                    System.out.println("输入不合法，请重新输入。");
                    change();
                    return;
                }
                setCount(cnt);
                break;
            default:
                System.out.println("输入不合法，请重新输入。");
                change();
                return;
        }
        System.out.println("是否继续修改？（输入yes继续修改）");
        if(input.next().equals("yes"))change();
    }
}
